package com.anghui.demo.controller;

import com.anghui.demo.annotations.Log;
import com.anghui.demo.domain.RmProject;
import com.anghui.demo.enums.BusinessType;
import com.anghui.demo.service.RmProjectService;
import com.anghui.demo.vo.request.ReqProjectVo;
import com.anghui.demo.vo.response.R;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/project")
public class RmProjectController {
    @Autowired
    private RmProjectService rmProjectService;

    @GetMapping("/selectAll")
    public R<IPage<RmProject>> selectAll() {
        return R.ok(rmProjectService.selectRmProjectList());
    }

    @GetMapping("/selectAllPlus")
    public R<IPage<RmProject>> selectAllPlus() {
        return R.ok(rmProjectService.selectRmProjectListPlus());
    }

    @PostMapping("/insertProject")
    @Log(title = "项目", businessType = BusinessType.INSERT, remark = "项目单条新增")
    public R<String> insertProject(@RequestBody @Valid ReqProjectVo reqProjectVo) {
        return R.ok(rmProjectService.insertProject(reqProjectVo));
    }

    @PutMapping("/updateProject")
    @Log(title = "项目", businessType = BusinessType.UPDATE, remark = "项目单条更新")
    public R<String> updateProject(@RequestBody @Valid ReqProjectVo reqProjectVo) {
        return R.ok(rmProjectService.updateProject(reqProjectVo));
    }

    @DeleteMapping("/deleteProjects")
    @Log(title = "项目", businessType = BusinessType.DELETE, remark = "项目删除测试")
    public R<String> deleteProjects() {
        return R.ok(rmProjectService.deleteProjects());
    }
}
